package com.xqboss.apps.vo.equipment;

import com.xqboss.apps.constant.Config;
import com.xqboss.common.utils.spring.SpringUtils;
import com.xqboss.system.service.ISysConfigService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author Trent
 * @date 2023/8/25
 */
@Data
@ApiModel
public class EquipmentInfoVo {

    @ApiModelProperty("装备ID")
    private Long id;
    @ApiModelProperty("总耐久度")
    private BigDecimal totalDurability;
    @ApiModelProperty("装备耐久度")
    private BigDecimal durability;
    @ApiModelProperty("总破损度")
    private BigDecimal totalBreakage;
    @ApiModelProperty("装备破损度")
    private BigDecimal breakage;
    @ApiModelProperty("装备稀有度")
    private Integer rarity;

    ////////////以下为装备基础属性值////////////////
    @ApiModelProperty("装备等级")
    private Integer level;
    @ApiModelProperty("装备幸运值")
    private Integer luck;
    @ApiModelProperty("装备天赋值")
    private Integer talent;
    @ApiModelProperty("装备耐久值")
    private Integer durable;
    @ApiModelProperty("装备坚固值")
    private Integer strong;
    @ApiModelProperty("装备总属性值")
    private Integer totalAttrCount;
    @ApiModelProperty("剩余加点")
    private Integer remainAttrCount;
    @ApiModelProperty("收益折算系数")
    private BigDecimal incomeRatio;

    @ApiModelProperty("装备是否损坏")
    private Boolean isBreakage;
    @ApiModelProperty("是否耐久度不足")
    private Boolean isInsDurability;

    @ApiModelProperty("打卡耐久度消耗")
    private BigDecimal durabilityExpend;
    @ApiModelProperty("打卡破损度消耗")
    private BigDecimal breakageExpend;

    @ApiModelProperty("打卡空投热豆")
    private BigDecimal punchAirdropBeans;
    @ApiModelProperty("剩余空投")
    private BigDecimal remainAirdrop;
    @ApiModelProperty("总空投")
    private BigDecimal totalAirdrop;
    @ApiModelProperty("剩余打卡次数")
    private Integer remainPunch;
    @ApiModelProperty("下次打卡空投值")
    private BigDecimal nextPunchAirdrop;


    /**
     * 耐久度消耗：消耗系数 * 总属性值
     * @return
     */
    public BigDecimal getDurabilityExpend() {
        return SpringUtils.getBean(ISysConfigService.class)
                .getValue(Config.Sys.Punch.耐久消耗系数)
                .multiply(BigDecimal.valueOf(getTotalAttrCount()))
                .setScale(2, RoundingMode.DOWN);
    }

    /**
     * 破损值消耗：破损值消耗值
     * @return
     */
    public BigDecimal getBreakageExpend() {
        return SpringUtils.getBean(ISysConfigService.class)
                .getValue(Config.Sys.Punch.消耗破损值);
    }
}
